package com.br.pfm.Controller;

import java.util.List;
import java.util.Locale;

import javax.servlet.http.HttpServletRequest;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.servlet.ModelAndView;

import com.br.pfm.BO.InstituicaoBO;
import com.br.pfm.VO.InstituicaoVO;

@Controller
public class InstituicaoController {
	
	private static final Logger logger = LoggerFactory.getLogger(InstituicaoController.class);
	
	@Autowired
	private InstituicaoBO instituicaoBO;
	
	@RequestMapping(value = "/", method = RequestMethod.GET)
	public ModelAndView home(Locale locale, Model model, HttpServletRequest request) {
		
		logger.info("Entrou no metodo do controller de pagina inicial.", locale);
		
		ModelAndView mv = new ModelAndView("home");
		
		List<InstituicaoVO> listInstituicaoVO = instituicaoBO.listarInstituicoes(); 
		
		mv.addObject("listaInstituicoes", listInstituicaoVO);
		
		return mv;
	}

}
